import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
let userInfo = sessionStorage.getItem("userInfoC")?JSON.parse(sessionStorage.getItem("userInfoC")):{};
let isLogin = userInfo.token ? true : false;
export default new Vuex.Store({
  state: {
    isLogin:isLogin,
    userInfo:userInfo
  },
  mutations: {
    login(state,item){
      state.isLogin = true;
      state.userInfo = item
      sessionStorage.setItem("userInfoC",JSON.stringify(item))
    },
    loginOut(state){
      state.isLogin = false;
      state.userInfo = {}
      sessionStorage.clear("userInfoC")
    }
  },
  actions: {
  },
  modules: {
  }
})

